//https://www.nowcoder.com/practice/41b42e7b3c3547e3acf8e90c41d98270?tpId=290&tqId=39852&ru=/exam/oj

#include <iostream>
using namespace std;

int express_fee(float a, char b) {
    int ret = 0;
    if (a <= 0) {
        return 0;
    }
    if (a <= 1.0 && a > 0) {
        ret = 20;
    }
    else if (a / 1.0f == (int)a) {
        ret = 20 + (int)a - 1;
    }
    else {
        ret = 20 + (int)a;
    }
    if (b == 'y') {
        ret += 5;
    }
    return ret;
}

int main() {
    float x;
    char y;
    cin >> x >> y;
    cout << express_fee(x, y) << endl;

}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    double a;
    char b;
    cin >> a >> b;
    int ret = 0;
    if (a <= 1)
    {
        ret += 20;
    }
    else
    {
        ret += 20;
        a -= 1;
        ret += ceil(a);
    }
    if (b == 'y') ret += 5;
    cout << ret << endl;
    return 0;
}

//https://www.nowcoder.com/practice/9b969a3ec20149e3b870b256ad40844e?tpId=230&tqId=39751&ru=/exam/oj
#include <iostream>
using namespace std;
const int N = 1e5 + 10;
int n;
int cost[N];
int dp[N];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> cost[i];
    for (int i = 2; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
    }
    cout << dp[n] << endl;
    return 0;
}



//https://www.nowcoder.com/questionTerminal/2c6a0a8e1d20492f92941400036e0890

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <memory>
#include<string>
#include<vector>
using namespace std;

int mindis(vector<string>& strs, string str1, string str2) {
    int a1 = -1;
    int a2 = -1;
    int ret = 10000;
    for (int i = 0; i < strs.size(); i++) {
        if (strs[i] == str1) {
            a1 = i;
            if (a2 != -1) {
                ret = min(ret, abs(a1 - a2));
            }
        }
        else if (strs[i] == str2) {
            a2 = i;
            if (a1 != -1) {
                ret = min(ret, abs(a1 - a2));
            }
        }
    }
    return (ret == 10000) ? -1 : ret;
}


int main() {
    int n = 0;
    cin >> n;
    string str1;
    cin >> str1;
    string str2;
    cin >> str2;
    string str;
    vector<string> strs;
    while (n) {
        cin >> str;
        strs.push_back(str);
        n--;
    }
    cout << mindis(strs, str1, str2) << endl;

}
